<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:c="http://java.sun.com/jsp/jstl/core"
                xmlns:fn="http://java.sun.com/jsp/jstl/functions"
                xmlns:ds="http://deltaset.org/deltaset-faces"
                xmlns:meta="http://deltaset.org/deltaset-meta"
                xmlns:mf="http://java.sun.com/jsf/composite/deltaset.meta/flow"
                xmlns:composite="http://java.sun.com/jsf/composite">
    <composite:interface componentType="org.deltaset.metaCrud">
        <composite:attribute name="entityClass" type="java.lang.String" required="true"/>
        <composite:attribute name="repositoryProvider" type="org.deltaset.meta.extension.RepositoryProvider" required="true"/>
        <composite:attribute name="metaType" type="java.lang.String" default="flow"/>
        <composite:attribute name="detailTemplate" type="java.lang.String" default="/META-INF/resources/deltaset.meta/flow/detailTemplate.xhtml"/>
        <composite:attribute name="executeTemplate" type="java.lang.String" default="/META-INF/resources/deltaset.meta/flow/executeTemplate.xhtml"/>
        <composite:attribute name="formTemplate" type="java.lang.String" default="/META-INF/resources/deltaset.meta/flow/formTemplate.xhtml"/>
        <composite:attribute name="listTemplate" type="java.lang.String" default="/META-INF/resources/deltaset.meta/flow/listTemplate.xhtml"/>
        <composite:attribute name="defaultView" type="java.lang.String" default="listTemplate"/>
        <composite:attribute name="catalogName" type="java.lang.String"/>
    </composite:interface>

    <composite:implementation>
        <c:set var="flowFormId" value="#{cc.meta.clientId}:flow-form"/>
        <h:form  id="flow-form">           
            <ds:titlebar title="#{cc.meta.labelEntity}" style="margin-bottom: 5px;">
                <div style="display:block">
                    <h:commandButton  value="Back"
                                      disabled="#{cc.meta.disabledPreviousView}"
                                      action="#{cc.meta.previousView}"
                                      styleClass="ds-button">
                        <f:ajax execute="@form" render="@form"/>					
                    </h:commandButton>
                    <h:commandLink  value="View All">
                        <f:ajax event="click" listener="#{cc.meta.showList}" render="@form"/>                        
                    </h:commandLink>
                    <h:panelGroup rendered="#{empty meta.executor}" layout="block">
                        <c:forEach items="#{cc.meta.factoryActions}" var="action">
                            <mf:commandButton metaAction="#{action}"
                                              model="#{cc.meta.model}"
                                              meta="#{cc.meta.meta}"                                          
                                              />
                        </c:forEach>

                        <c:forEach items="#{cc.meta.otherActions}" var="action">
                            <mf:commandButton metaAction="#{action}"
                                              model="#{cc.meta.model}"
                                              meta="#{cc.meta}"                                         
                                              style="font-size: 0.8em;"
                                              />
                        </c:forEach>
                    </h:panelGroup>
                </div>
            </ds:titlebar>
            <ui:include src="#{cc.currentViewTemplate}">
                <ui:param name="meta" value="#{cc.meta}"/>
                <ui:param name="formId" value="#{flowFormId}"/>
            </ui:include>
        </h:form>	
    </composite:implementation>

</ui:composition>
